const router = require('koa-router')();
const isLoggedIn=require('../middlewares/isLoggedIn');

router.get('/',isLoggedIn(), async ctx => {
    await ctx.render('post', {
        title: [ctx.locals.name, 'Post'].join('-'),
        loginUser: ctx.state.user,
        success: ctx.flash.success,
        error: ctx.flash.error
    });
});

router.post('/',isLoggedIn(), ctx=>{
    if(ctx.isAuthenticated()){
        ctx.body={
            code:200,
            msg:'Success'
        }
    }else{
        ctx.body={
            code:401,
            msg:'Unauthorized'
        }
    }
});


module.exports = router;